from flask_script import Manager, Server

from app import create_app, db
from app.models import Role

app = create_app('default')
manager = Manager(app)
manager.add_command("runserver", Server('0.0.0.0'))

@manager.command
def create_db():
    db.create_all()
    Role.insert_roles()

@manager.command
def test():
    import unittest
    tests = unittest.TestLoader().discover('test')
    unittest.TextTestRunner(verbosity=2).run(tests)


if __name__ == '__main__':
    manager.run()